<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue按键修饰符</title>
</head>
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.8"></script>
<body>
    <div id="app">
        <!-- keyup键盘事件 -->
        <input type="text" @keyup.esc="clearInput" @keyup.enter="clearEnter">  
        <input type="text" @keyup.enter="clearInput">  

    </div>
    <script>
        const vm = new Vue({
            el:"#app",
            data:{

            },
            methods: {
                clearInput(e){
                    e.target.value = '';  //点击esc按钮情况input的内容   必须获取焦点的情况!
                    console.log('触发了一次')
                },
                clearEnter(e){
                    e.target.value='';
                    console.log('触发enter的方法');
                }
            },
        });
    </script>
</body>
</html>